

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[spPlate_InsertPlate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spPlate_InsertPlate]
GO

GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Eric Liew
-- Create date: 6/2/2009
-- Description:	Insert a Plate
-- =============================================
CREATE PROCEDURE [dbo].[spPlate_InsertPlate]
(
	@PlateNumber Varchar(10),
	@OwnerId Int,
	@PlateTypeId INT,
	@Account Varchar(50),
	@Bank Varchar(50),
	@Comment Varchar(500),
	@EndDate DATETIME,
	@StartDate DATETIME,
	@GST Varchar(50),
	@MonthlyRate Varchar(50),
	@WeeklyRate Varchar(50)
)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @PlateId int;

	INSERT Plate
	(
		PlateNumber,
		OwnerId,
		PlateTypeId
	)
	VALUES
	(
		@PlateNumber,
		@OwnerId,
		@PlateTypeId
	) 	
	
	SET @PlateId = @@IDENTITY 
 
	INSERT PlateFinancial
	(PlateId,WeeklyRate,GST,MonthlyRate,StartDate,
	EndDate,Bank,Account,Comment)
	VALUES
	(@PlateId, @WeeklyRate, @GST, @MonthlyRate, @StartDate,
	@EndDate, @Bank, @Account, @Comment)

 

END
GO
